package com.example.zheng.els2.service;


import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;

import com.example.zheng.els2.R;
import com.example.zheng.els2.activity.GameActivity;


public class NotificationService extends Service{

    @Override
    public void onCreate() {
        super.onCreate();
        Intent intent=new Intent(this, GameActivity.class);
        PendingIntent pi=PendingIntent.getActivity(this,0,intent,0);
        NotificationManager manager=(NotificationManager)getSystemService(NOTIFICATION_SERVICE);
        Notification.Builder builder=new Notification.Builder(this);
        builder.setContentText("游戏暂停中")
                .setContentTitle("俄罗斯方块")
                .setWhen(System.currentTimeMillis())
                .setSmallIcon(R.drawable.logo)
                .setAutoCancel(true)
                .setContentIntent(pi);
        startForeground(1,builder.build());
    }

    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }
}
